package com.linzhaowei.headhuntingservice;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.linzhaowei.headhuntingservice.fragment.ApplicantJobInformationFragment;
import com.linzhaowei.headhuntingservice.fragment.EMChatFragment;
import com.linzhaowei.headhuntingservice.fragment.InterviewerJobObjectiveFragment;
import com.linzhaowei.headhuntingservice.fragment.InterviewerPersonalFragment;

public class InterviewerMain extends AppCompatActivity implements View.OnClickListener{

    private Button jobObjective;
    private Button message;
    private Button personal;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_interviewermain);

        replaceFragment(new InterviewerJobObjectiveFragment());
        initViews();
        setEvents();
    }



    /**
     * 绑定组件
     */
    private void initViews(){
        jobObjective=findViewById(R.id.i_job_objective);
        message=findViewById(R.id.i_message);
        personal=findViewById(R.id.i_personal);

    }

    /**
     * 绑定事件
     */
    private void setEvents(){
        jobObjective.setOnClickListener(this);
        message.setOnClickListener(this);
        personal.setOnClickListener(this);

    }

    /**
     * 点击事件
     * @param v
     */
    @Override
    public void onClick(View v){
        switch (v.getId()){
            case R.id.i_job_objective:
                replaceFragment(new InterviewerJobObjectiveFragment());
                break;
            case R.id.i_personal:
                replaceFragment(new InterviewerPersonalFragment());
                break;
            case R.id.i_message:
                replaceFragment(new EMChatFragment());
                break;

            default:
                break;
        }

    }


    /**
     * 刷新Fragment界面
     * @param fragment
     */
    private void replaceFragment(Fragment fragment){
        FragmentManager fragmentManager=getSupportFragmentManager();
        FragmentTransaction transaction=fragmentManager.beginTransaction();
        transaction.replace(R.id.interviewer_up_layout,fragment);
        transaction.commit();
    }
}
